﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WeekWork929.Api.Write.Appliaction.Commond;
using WeekWork929.ErrorCode;

namespace WeekWork929.Api.Write.Controllers
{
    /// <summary>
    /// Api-读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QueryController : ControllerBase
    {
        IMediator mediator;

        public QueryController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 增加部门
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回增加信息</returns>
        [HttpPost]
        public async Task<ApiResult<int>> MasenAdd(MasenAddCommond request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 增加岗位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回增加信息</returns>
        [HttpPost]
        public async Task<ApiResult<int>> WorkAdd(WorkAddCommond request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除岗位信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回删除信息</returns>
        [HttpDelete]
        public async Task<ApiResult<int>> WorkDel([FromQuery]MasenDelCommond request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回修改信息</returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateWork(UpdateCommond request)
        {
            return await mediator.Send(request);
        }
    }
}
